
--[[

    slimui - Copyright (c) 2011 atom0s, All rights reserved.

    See Copyright notice in slimui.lua
    
]]--

class 'Image: GraphicControl' { ... };

----------------------------------------------------------------------------------
-- func: Image.__init__
-- desc: Constructor called when this object is first created.
----------------------------------------------------------------------------------
function Image.__init__( self )
    GraphicControl.__init__( self );
end

----------------------------------------------------------------------------------
-- func: Image:Create
-- desc: Creates a new Image object.
----------------------------------------------------------------------------------
function Image:Create( parent )
    if parent == nil or parent._object == nil then
        slimui:err( 'Image:Create - parent must be set to create a control!' );
    end
    
    self._object = createImage( parent._object );
    
    if self._object == nil then
        slimui:err( 'Image:Create failed to initialize a new image object.' );
    end
    
    return self;
end

----------------------------------------------------------------------------------
-- func: Image:LoadImageFromFile
-- desc: Loads the given image file.
----------------------------------------------------------------------------------
function Image:LoadImageFromFile( filename )
    image_loadImageFromFile( self._object, filename );
end

----------------------------------------------------------------------------------
-- func: Image:Stretch
-- desc: Sets the stretch property of this object.
----------------------------------------------------------------------------------
function Image:Stretch( stretch )
    image_stretch( self._object, stretch );
end

----------------------------------------------------------------------------------
-- func: Image:Transparent
-- desc: Sets the transparency property of this object.
----------------------------------------------------------------------------------
function Image:Transparent( trans )
    image_transparent( self._object, trans );
end

----------------------------------------------------------------------------------
-- func: Image:GetCanvas
-- desc: Returns the canvas of this object.
----------------------------------------------------------------------------------
function Image:GetCanvas( )
    return image_getCanvas( self._object );
end

----------------------------------------------------------------------------------
-- func: Image:GetPicture
-- desc: Returns the picture of this object.
----------------------------------------------------------------------------------
function Image:GetPicture( )
    return image_getPicture( self._object );
end



--[[ Debug information. ]]--------------------------------------------------------
if ( slimui:isdebug() == true ) then
    slimui:msg( '(Control) image.lua successfully loaded.' );
end